<?xml version="1.0" encoding="windows-1251" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
	xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:owl="http://www.w3.org/2002/07/owl#"
        >
    <xsl:output method="xml" encoding="utf-8"/>
    <xsl:param name="prefixID"/>
    <xsl:param name="projectAlias"/>

    <xsl:template match="/">

       <!-- <xsl:namespace-alias stylesheet-prefix="rdf" result-prefix="rdf"/>
        <xsl:namespace-alias stylesheet-prefix="rdfs" result-prefix="rdfs"/>
        <xsl:namespace-alias stylesheet-prefix="owl" result-prefix="owl"/>-->

       <!-- <xsl:element name="rdf:RDF" namespace="http://niimm.edu.ru/mom/src_models/NMRT/" >
            <xsl:attribute name="rdfs">http://www.w3.org/2000/01/rdf-schema#</xsl:attribute>
            <xsl:attribute name="owl">http://www.w3.org/2002/07/owl#</xsl:attribute>-->


        <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                 xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
			xmlns:owl="http://www.w3.org/2002/07/owl#"
            xmlns="http://www.rbm.ru#"


            >
            <owl:Ontology rdf:about=""/>
            <!--xsl:variable name="this" select="." /-->
			<!-- FOR KAMIS

			xmlns="http://emku.ksu.ru#"
			-->
			<!--xsl:for-each select="document('../files.xml')/files/url" >
	<xsl:variable name="fn" select="." /> xmlns="http://niimm.edu.ru/source/instances#"
	<xsl:apply-templates select="document($fn)/*" mode="class">
			<xsl:with-param name="file"  select="$fn" />
	</xsl:apply-templates>
</xsl:for-each-->
			<!-- FOR KGTU -->
			
				
				<xsl:apply-templates select="./*" mode="class"/>
					
				
			
			<!-- FOR EMKU-->
			<!--xsl:for-each select="document('../EMKU_files.xml')/files/url" >
	<xsl:variable name="fn" select="." />
	<xsl:apply-templates select="document($fn)/*" mode="class">
			<xsl:with-param name="file"  select="$fn" />
	</xsl:apply-templates>
</xsl:for-each-->
			<!-- FOR MIKU>

<xsl:for-each select="document('../MIKU_files.xml')/files/url" >
	<xsl:variable name="fn" select="." />
	<xsl:apply-templates select="document($fn)/*" mode="class">
			<xsl:with-param name="file"  select="$fn" />
	</xsl:apply-templates>
</xsl:for-each-->
			<!-- FOR VRM  (files 1 - 500 )-->
			<!--xsl:for-each select="document('../VRM_files1-500.xml')/files/url" >
	<xsl:variable name="fn" select="." />
	<xsl:apply-templates select="document($fn)/*" mode="class">
			<xsl:with-param name="file"  select="$fn" />
	</xsl:apply-templates>
</xsl:for-each-->
			<!--xsl:apply-templates select="/."  mode="class" /-->
        <!--</xsl:element>-->
        </rdf:RDF>
	</xsl:template>
	
	<xsl:template match="*" mode="class">
		<xsl:element name="owl:Class">
			<xsl:attribute name="rdf:ID"><xsl:value-of select="name(.)" />
			</xsl:attribute>
		</xsl:element>
		<xsl:variable name="name">
			<xsl:value-of select="name(.)" />
		</xsl:variable>
		<xsl:element name="{$name}" >
			<xsl:attribute name="rdf:ID"><xsl:value-of select="name(.)" />_<xsl:value-of select="$prefixID" />_<xsl:value-of select="generate-id(.)" /></xsl:attribute>
		</xsl:element>
		<xsl:apply-templates select="./*" mode="relation" />
	</xsl:template>
	
	<xsl:template match="*" mode="relation">
		<xsl:element name="owl:ObjectProperty">
			<xsl:attribute name="rdf:ID"><xsl:value-of select="name(ancestor::*[position()=1])" />_____<xsl:value-of select="name(.)" /></xsl:attribute>
			<xsl:element name="rdfs:domain">
				<xsl:attribute name="rdf:resource">#<xsl:value-of select="name(ancestor::*[position()=1])" /></xsl:attribute>
			</xsl:element>
			<xsl:element name="rdfs:range">
				<xsl:attribute name="rdf:resource">#<xsl:value-of select="name(.)" /></xsl:attribute>
			</xsl:element>
			<xsl:element name="owl:inverseOf">
				<xsl:element name="owl:ObjectProperty">
					<xsl:attribute name="rdf:ID"><xsl:value-of select="name(.)" />_____<xsl:value-of select="name(ancestor::*[position()=1])" /></xsl:attribute>
					<xsl:element name="rdfs:range">
						<xsl:attribute name="rdf:resource">#<xsl:value-of select="name(ancestor::*[position()=1])" /></xsl:attribute>
					</xsl:element>
					<xsl:element name="rdfs:domain">
						<xsl:attribute name="rdf:resource">#<xsl:value-of select="name(.)" /></xsl:attribute>
					</xsl:element>
				</xsl:element>
			</xsl:element>
		</xsl:element>
		<xsl:apply-templates select="." mode="class" />
		
		<xsl:call-template name="print-instance">
			<xsl:with-param name="domain">
				<xsl:value-of select="name(ancestor::*[position()=1])" />
			</xsl:with-param>
			<xsl:with-param name="relation"><xsl:value-of select="name(ancestor::*[position()=1])" />_____<xsl:value-of select="name(.)" /></xsl:with-param>
			<xsl:with-param name="relation-inverse"><xsl:value-of select="name(.)" />_____<xsl:value-of select="name(ancestor::*[position()=1])" /></xsl:with-param>
			<xsl:with-param name="range">
				<xsl:value-of select="name(.)" />
				
			</xsl:with-param>
			<xsl:with-param name="range-value"><xsl:value-of select="text()"/></xsl:with-param>
		</xsl:call-template>
		
		<xsl:apply-templates select="./*" mode="class" />
	</xsl:template>
	
	<xsl:template name="print-instance">
		<xsl:param name="domain" />
		<xsl:param name="relation" />
		<xsl:param name="relation-inverse" />
		<xsl:param name="range" />
		<xsl:param name="range-value" />
		<xsl:element name="{$domain}" >
            <xsl:attribute name="rdf:ID"><xsl:value-of select="$domain" />_<xsl:value-of select="$prefixID" />_<xsl:value-of select="generate-id(ancestor::*[position()=1])" /></xsl:attribute>
			<xsl:element name="{$relation}" >
				<xsl:element name="{$range}" >
					<xsl:attribute name="rdf:ID"><xsl:value-of select="$range" />_<xsl:value-of select="$prefixID" />_<xsl:value-of select="generate-id(.)" /></xsl:attribute>
					<xsl:element name="{$relation-inverse}" >
						<xsl:element name="{$domain}" >
							<xsl:attribute name="rdf:ID"><xsl:value-of select="$domain" />_<xsl:value-of select="$prefixID" />_<xsl:value-of select="generate-id(ancestor::*[position()=1])" /></xsl:attribute>
						</xsl:element>
					</xsl:element>
					<xsl:element name="rdfs:label">
						<xsl:attribute name="xml:lang">ru</xsl:attribute>
						<xsl:value-of select="$range-value" />
					</xsl:element>
				</xsl:element>
			</xsl:element>
		</xsl:element>
	</xsl:template>
	
</xsl:stylesheet>